import time

from selenium.webdriver.common.by import By

from common.Untils import QESDriver

# 登录页面
class LoginPage:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://8.155.1.153:8081/user/login"
        self.driver = QESDriver.driver
        self.driver.get(self.url)

    def GetLoginPage(self):
        # 不输入用户名点击登录
        self.driver.find_element(By.XPATH,'//*[@id="root"]/div/div[2]/div[2]/div/form/button').click()
        time.sleep(0.5)
        QESDriver.GetScreenShot()
################################################################################################
        # 查找用户名输入栏并输入“xiaowang”
        self.driver.find_element(By.XPATH,'//*[@id="username"]').send_keys("xiaowang")
        # 查找密码输入栏并输入错误密码“654321”
        self.driver.find_element(By.XPATH,'//*[@id="password"]').send_keys("654321")
        # 使用错误密码并点击登录然后截图展示
        self.driver.find_element(By.XPATH,'//*[@id="root"]/div/div[2]/div[2]/div/form/button').click()
        time.sleep(0.5)
        QESDriver.GetScreenShot()
#########################################################################################################
        # 使用正确密码登录并截图查看
        # 先清空，再输入正确密码
        QESDriver.ClearInput(self.driver.find_element(By.XPATH,'//*[@id="password"]'))
        self.driver.find_element(By.XPATH,'//*[@id="password"]').send_keys("123456")
        self.driver.find_element(By.XPATH,'//*[@id="root"]/div/div[2]/div[2]/div/form/button').click()
        time.sleep(0.5)
        QESDriver.GetScreenShot()

